Getting Started
To get started, perform following steps:
- Download the program to a target board.
- Connect the USB cable to a PC host and open a serial terminal at 115200 baud, 8-bits no parity, 1 stop bit.
- Reset the board, after that, shell welcome information will be displayed on terminal. you can type "help" for more information. Communication Interface Settings:
- TWR-K64F120M(OpenSDA) UART1 TX: PC3 RX: PC4.
- FRDM-K64F120M(OpenSDA) UART0 TX: PC17 RX: PC16.
HOWTO Customization
You can customize shell system and register your command to shell. Those macro located in shell_config.h.
Functional configuration
to enable shell auto complete support, use the following:
#define SHELL_CONFIG_AUTO_COMPLETE
to enable shell history support, use the following:
#define SHELL_CONFIG_USE_STDIO
use this macro to configure if stdout will be connected to shell input and output.
#define SHELL_CONFIG_USE_STDIO
Configure consult and history record buffer size
Change the following macro to configure characters for read line input. generally HIST_SIZE should be equal to SHELL_CB_SIZE
#define SHELL_CB_SIZE (128)
#define HIST_SIZE SHELL_CB_SIZE
Configure max numbers of commands and command arguments
Change the following macro to configure max arguments for all commands.
#define SHELL_MAX_ARGS (8)
Change the following macro to configure max function number
#define SHELL_MAX_FUNCTION_NUM (64)
Add command
To register your own function to the mini shell, perform those steps:
- Define a command function table and fill in the table with register information.
- Two ways to register your command to shell:
use
shell_register_function(const cmd_tbl_t * pAddress) to register single commands.
use
shell_register_function_array(const cmd_tbl_t * pAddress, uint8_t num) to register mutilple commands.
command function table struct is located in
shell.h. as follow:
typedef struct
{
char *name;
uint8_t maxargs;
uint8_t repeatable;
int (*cmd)(int argc, char * const argv[]);
char *usage;
char *help;
int (*complete)(int argc, char * const argv[], char last_char, int maxv, char *cmdv[]);
Example for register command struct
{
.maxargs = 5,
.repeatable = 1,
.usage = "help - app test function",
.complete = NULL,
.help = "long help - app test function",
};